package com.zbkj.service.service.order.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zbkj.common.model.order.ReciveAccount;
import com.zbkj.common.response.order.ReciveAccountResponse;
import com.zbkj.service.dao.order.ReciveAccountMapper;
import com.zbkj.service.service.order.ReciveAccountService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * <p>
 * 收款信息表 服务实现类
 * </p>
 *
 * @author 
 * @since 2024-09-15
 */
@Service
public class ReciveAccountServiceImpl extends ServiceImpl<ReciveAccountMapper, ReciveAccount> implements ReciveAccountService {


    @Override
    public ReciveAccount getReciveAccount() {
        LambdaQueryWrapper<ReciveAccount> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ReciveAccount::getDeleteFlag, 0);
        return this.getOne(queryWrapper,false);
    }

    @Override
    public ReciveAccountResponse getReciveAccountResponse() {
        ReciveAccount account = this.getReciveAccount();
        if(Objects.isNull(account)) {
            return null;
        }
        ReciveAccountResponse response = new ReciveAccountResponse();
        BeanUtils.copyProperties(account, response);
        return response;
    }
}
